/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package taganalysistoolsclient;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author lendle
 */
public class TestCategory {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception{
        // TODO code application logic here
        BufferedReader reader=new BufferedReader(
                    new InputStreamReader(
                        new FileInputStream(
                            new File("computer.data.log")
                        ),
                        "utf-8")
               );
        
        PrintWriter writer=new PrintWriter(new OutputStreamWriter(
                    new FileOutputStream("applications\\delicious\\computer.category"), "utf-8"
                ));
        String str=reader.readLine();
        Map<String, String> tempMap=new HashMap<String, String>();
        boolean first=true;
        
        while(str!=null){
            String [] array=str.split("(\\s)+");
            String urlString=array[1].trim();
            URL url=new URL(urlString);
            if(!first){
                writer.println("");
            }
            first=false;
            if(tempMap.containsKey(urlString)==false){
                tempMap.put(urlString, "");
                System.out.println(urlString);
                writer.print(urlString);
            }
            str=reader.readLine();
        }
        
        writer.close();
        reader.close();
    }
}
